package com.flyqiu.flow.starter;

import com.flyqiu.flow.api.service.*;
import com.flyqiu.flow.api.service.base.FlowCommentService;
import com.flyqiu.flow.api.service.base.FlowVariableService;
import com.flyqiu.flow.api.service.hi.FlowHiVariableService;
import com.flyqiu.flow.api.service.hi.HiIdentityLinkService;
import com.flyqiu.flow.api.service.ru.FlowRuVariableService;
import com.flyqiu.flow.api.service.ru.RuIdentityLinkService;
import com.flyqiu.flow.core.impl.*;
import com.flyqiu.flow.core.impl.base.FlowCommentServiceImpl;
import com.flyqiu.flow.core.impl.hi.FlowHiVariableServiceImpl;
import com.flyqiu.flow.core.impl.hi.HiIdentityLinkServiceImpl;
import com.flyqiu.flow.core.impl.ru.FlowRuActivityServiceImpl;
import com.flyqiu.flow.core.impl.ru.FlowRuUserTaskServiceImpl;
import com.flyqiu.flow.core.impl.ru.FlowRuVariableServiceImpl;
import com.flyqiu.flow.core.impl.ru.RuIdentityLinkServiceImpl;
import com.flyqiu.flow.mapper.CommentMapper;
import org.springframework.context.annotation.Bean;

public class FlyQiuFlowSpringCoreServiceConfig {
    private final CommentMapper mapper;
    private final FlyQiuFlowSpringGlobalContext globalContext;

    private FlowModelService flowModelService;

    private FlowRuVariableService flowRuVariableService;
    private FlowHiVariableService flowHiVariableService;
    private FlowVariableService flowVariableService;
    private FlowRuActivityService ruActivityService;
    private HiIdentityLinkService hiIdentityLinkService;
    private RuIdentityLinkService ruIdentityLinkService;
    private IdentityLinkService identityLinkService;
    private FlowRuUserTaskService flowRuUserTaskService;
    private FlowCommentService flowCommentService;
    private FlowRunningService flowRunningService;
    private FlowHistoryService flowHistoryService;
    private FlowTaskService flowTaskService;


    public FlyQiuFlowSpringCoreServiceConfig(CommentMapper mapper, FlyQiuFlowSpringGlobalContext globalContext) {
        this.mapper = mapper;
        this.globalContext = globalContext;
        initService();
    }

    private void initService() {
        //模型服务
        flowModelService = new FlowModelServiceImpl(globalContext);
        //变量服务
        flowRuVariableService = new FlowRuVariableServiceImpl(globalContext);
        flowHiVariableService = new FlowHiVariableServiceImpl(globalContext);
        flowVariableService = new FlowVariableServiceImpl(globalContext, flowRuVariableService, flowHiVariableService);
        //活动服务
        ruActivityService = new FlowRuActivityServiceImpl(globalContext);
        //用户信息服务
        hiIdentityLinkService = new HiIdentityLinkServiceImpl(globalContext);
        ruIdentityLinkService = new RuIdentityLinkServiceImpl(globalContext);
        identityLinkService = new IdentityLinkServiceImpl(globalContext, ruIdentityLinkService, hiIdentityLinkService);
        //用户任务服务
        flowRuUserTaskService = new FlowRuUserTaskServiceImpl(globalContext);
        //评判备注服务
        flowCommentService = new FlowCommentServiceImpl(mapper);


        //运行时服务
        flowRunningService = new FlowRunningServiceImpl(globalContext, flowCommentService, identityLinkService, flowVariableService);
        //历史服务
        flowHistoryService = new FlowHistoryServiceImpl(globalContext, flowCommentService, identityLinkService, flowVariableService);
        //任务服务
        flowTaskService = new FlowTaskServiceImpl(globalContext, flowCommentService, identityLinkService, flowVariableService);
    }


    @Bean
    public FlowRuVariableService flowRuVariableService() {
        return flowRuVariableService;
    }

    @Bean
    public FlowHiVariableService flowHiVariableService() {
        return flowHiVariableService;
    }

    @Bean
    public FlowVariableService flowVariableService() {
        return flowVariableService;
    }

    @Bean
    public FlowRuActivityService flowRuActivityService() {
        return ruActivityService;
    }

    @Bean
    public HiIdentityLinkService flowHiIdentityLinkService() {
        return hiIdentityLinkService;
    }

    @Bean
    public RuIdentityLinkService flowRuIdentityLinkService() {
        return ruIdentityLinkService;
    }

    @Bean
    public IdentityLinkService flowIdentityLinkService() {
        return identityLinkService;
    }

    @Bean
    public FlowRuUserTaskService flowRuUserTaskService() {
        return flowRuUserTaskService;
    }

    @Bean
    public FlowCommentService flowCommentService() {
        return flowCommentService;
    }

    @Bean
    public FlowModelService flowModelService() {
        return flowModelService;
    }

    @Bean
    public FlowTaskService flowTaskService() {
        return flowTaskService;
    }

    @Bean
    public FlowRunningService flowRunningService() {
        return flowRunningService;
    }

    @Bean
    public FlowHistoryService flowHistoryService() {
        return flowHistoryService;
    }


}
